import { Repository } from "@/atoms/api_repositories"
import { atom } from "jotai"

//UserCenterTop
export const progressAtom = atom<number>(0) //进度条进度

//统一聚合atom后派生，获取userinfo
interface UserInfo {
    nickname?: string
    username?: string
    avatarUrl?: string
    uid?: string
}

export const LoginAgreeValueAtom = atom({
    value: false,
    changeType: "",
})

export const UserInfoAtom = atom<UserInfo | null>(null)
export const vipLevelAtom = atom<string>("VIP 6 (Bronze)") // VIP 等级
export const vipNextAtom = atom<string>("VIP 6") // VIP 等级

export const isCopiedAtom = atom<boolean>(false) //管理复制状态

/* UserCenterBottom */
//UserCenterBalance
export const balanceAtom = atom<number>(0) //初始化余额
interface BtnProps {
    name: string
    clicked: boolean
}
//存款取款按钮显示
export const balanceBtnStateAtom = atom<BtnProps>({
    name: "",
    clicked: false,
})
//balanceIcon底部4个
export const balanceIconStateAtom = atom<BtnProps>({
    name: "",
    clicked: false,
})

//yesterday's Earnings
export const earningsBtnStateAtom = atom<BtnProps>({
    name: "",
    clicked: false,
})
export const InviteEarnAtom = atom<number>(2000) //初始化邀请奖励
export const MissionPointsAtom = atom<number>(2000) //初始化任务积分
interface EarningsButton {
    color: string
    borderColor: string
    icon?: React.ReactNode | string | null
    name: string
    balance: string
    onClick?: () => void
}
export const EarningsButtonAtom = atom<EarningsButton[]>([
    {
        color: "linear-gradient(90deg, #FFFFFF 0%, #FFE6EC 100%)",
        borderColor: "#FFCCD9",
        icon: null,
        name: "Earnings",
        balance: "2000",
    },
])

//Games
interface ImageData {
    src: string
    alt: string
    name: string
}

interface CategoryData {
    recentlyPlayed: ImageData[]
    favorite: ImageData[]
}

interface CategoryTitle {
    title: string
    key?: string
}
//当前选中的类目
export const activeCategoryAtom = atom<number>(0)
//类目数据
export const categoryTitleAtom = atom<CategoryTitle[]>([])
//显示的游戏图
export const gameImagesAtom = atom<CategoryData>({
    recentlyPlayed: [],
    favorite: [],
})

//UserCenterHelp
// 主题状态（light 或 dark）
export const themeAtom = atom<"light" | "dark">("light")

//feedback
export const feedbackAtom = atom<string>("")
export const errorAtom = atom<string | null>(null)
export const isFocusedAtom = atom<boolean>(false)
export const currentLengthAtom = atom<number>(0)

//helpcenter
export const helpActiveIndexAtom = atom<number>(0)
interface activePanelAtom {
    sectionIndex: number
    panelIndex: number
}
export const activePanelAtom = atom<activePanelAtom | null>(null)

//language
export const selectedLanguageAtom = atom<string>("English")

//deposit
// 支付方式类型
export type PaymentMethodAtom =
    | "maya"
    | "gcash"
    | "grab"
    | "Lazada"
    | "BDO"
    | "BPI"
    | "CIMB"
    | "LANDBANK"
    | "Opay"
    | "Monzo"
    | "Gotyme"
    | "RCBC"
    | "UB"
// 全局状态，存储选择的支付方式
export const selectedPaymentMethodAtom = atom<string | null>(null)

//输入框中的实时金额
export const amountAtom = atom<number | string | null>(null)
//存储选中的金额
export const selectedAmountAtom = atom<number | null>(null)
